package hc.bre.cmn.struct

import com.fasterxml.jackson.annotation.JsonInclude

import hc.bre.cmn.ListOption
import hc.bre.cmn.ILoad
import hc.bre.cmn.TreeOption
import hc.bre.variable.VariableItem

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true,includePackage=false)
class DataStructItem extends TreeOption<DataStructItem>{
	/*
	 * id	: used for dynamic properties;
	 * code : property name of result;
	 * name : display name of property;
	 */
	String type = 'text';
	int important;		//importance for user to map
	
	@Override
	public DataStructItem load(Map map) {
		super.load(map);
		type = map['type'];
		important = map['important'] as Integer?:0;
		return this;
	}
	
	public String accessRouteOf(int id) {
		List<DataStructItem> lst = (List<DataStructItem>)this.routeOf(id);
		return lst.collect{it.code}.join('.')
	}
}
